Parent Thread exiting before Child Threads [python]

Posted by crgwbr on Stack Overflow See other posts from Stack Overflow or by crgwbr
Published on 2010-05-17T15:50:51Z Indexed on 2010/05/17 16:51 UTC
Read the original article Hit count: 173

I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs to send an occasional email (when a user registers or something else important happens). Since communicating with an SMTP server takes a long time, I'd like to spawn a thread for the mail function so that the rest of the app can finish up the request without waiting for the email to finish sending.

I tried using thread.start_new(func, (args)), but the Parent return's and exits before the sending is complete, thereby killing the sending process before it does anything useful. Is there anyway to keep the process alive long enough for the child process to finish?

© Stack Overflow or respective owner

Related posts about python

Related posts about multithreading